/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.ComponentTypeList;
import de.thwildau.tm.moses.asn1.asn1.ExtensionAndException;
import de.thwildau.tm.moses.asn1.asn1.SetType;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Set Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.SetTypeImpl#getExtensionAndException <em>Extension And Exception</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.SetTypeImpl#getComponentTypeList <em>Component Type List</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SetTypeImpl extends ContainerTypeImpl implements SetType
{
  /**
   * The cached value of the '{@link #getExtensionAndException() <em>Extension And Exception</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExtensionAndException()
   * @generated
   * @ordered
   */
  protected ExtensionAndException extensionAndException;

  /**
   * The cached value of the '{@link #getComponentTypeList() <em>Component Type List</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getComponentTypeList()
   * @generated
   * @ordered
   */
  protected ComponentTypeList componentTypeList;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SetTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.SET_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ExtensionAndException getExtensionAndException()
  {
    return extensionAndException;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetExtensionAndException(ExtensionAndException newExtensionAndException, NotificationChain msgs)
  {
    ExtensionAndException oldExtensionAndException = extensionAndException;
    extensionAndException = newExtensionAndException;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION, oldExtensionAndException, newExtensionAndException);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExtensionAndException(ExtensionAndException newExtensionAndException)
  {
    if (newExtensionAndException != extensionAndException)
    {
      NotificationChain msgs = null;
      if (extensionAndException != null)
        msgs = ((InternalEObject)extensionAndException).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION, null, msgs);
      if (newExtensionAndException != null)
        msgs = ((InternalEObject)newExtensionAndException).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION, null, msgs);
      msgs = basicSetExtensionAndException(newExtensionAndException, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION, newExtensionAndException, newExtensionAndException));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ComponentTypeList getComponentTypeList()
  {
    return componentTypeList;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetComponentTypeList(ComponentTypeList newComponentTypeList, NotificationChain msgs)
  {
    ComponentTypeList oldComponentTypeList = componentTypeList;
    componentTypeList = newComponentTypeList;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST, oldComponentTypeList, newComponentTypeList);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setComponentTypeList(ComponentTypeList newComponentTypeList)
  {
    if (newComponentTypeList != componentTypeList)
    {
      NotificationChain msgs = null;
      if (componentTypeList != null)
        msgs = ((InternalEObject)componentTypeList).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST, null, msgs);
      if (newComponentTypeList != null)
        msgs = ((InternalEObject)newComponentTypeList).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST, null, msgs);
      msgs = basicSetComponentTypeList(newComponentTypeList, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST, newComponentTypeList, newComponentTypeList));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION:
        return basicSetExtensionAndException(null, msgs);
      case Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST:
        return basicSetComponentTypeList(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION:
        return getExtensionAndException();
      case Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST:
        return getComponentTypeList();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION:
        setExtensionAndException((ExtensionAndException)newValue);
        return;
      case Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST:
        setComponentTypeList((ComponentTypeList)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION:
        setExtensionAndException((ExtensionAndException)null);
        return;
      case Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST:
        setComponentTypeList((ComponentTypeList)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.SET_TYPE__EXTENSION_AND_EXCEPTION:
        return extensionAndException != null;
      case Asn1Package.SET_TYPE__COMPONENT_TYPE_LIST:
        return componentTypeList != null;
    }
    return super.eIsSet(featureID);
  }

} //SetTypeImpl
